/*
package com.lazy.utils.lock;

import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

*/
/**
 * redis分布式锁
 * @author wql
 * @since  2018-02-05 15:54
 *//*

@Component
public class DistributedLockImpl implements DistributedLockService {

    @Autowired
    private RedissonClient redissonClient;

    */
/**
     * 默认锁时间 30s , 防止死锁
     *
     * @param lockKey 锁
     *//*

    @Override
    public void lock(String lockKey) {
        RLock lock = redissonClient.getLock(lockKey);
        lock.lock();
    }

    */
/**
     * 释放锁
     *
     * @param lockKey 锁
     *//*

    @Override
    public void unlock(String lockKey) {
        RLock lock = redissonClient.getLock(lockKey);
        lock.unlock();
    }

    @Override
    public void lock(String lockKey, int leaseTime) {
        RLock lock = redissonClient.getLock(lockKey);
        lock.lock(leaseTime, TimeUnit.SECONDS);
    }


    @Override
    public void lock(String lockKey, TimeUnit unit, int timeout) {
        RLock lock = redissonClient.getLock(lockKey);
        lock.lock(timeout, unit);
    }

    */
/**
     * 尝试获取锁，获取不到直接放弃
     *
     * @param lockKey 锁
     * @return 是否获得锁
     *//*

    @Override
    public boolean tryLock(String lockKey) {
        RLock lock = redissonClient.getLock(lockKey);
        return lock.tryLock();
    }

    */
/**
     * 竞争锁
     *
     * @param lockKey 锁
     * @param tryTimeOut 竞争时间
     * @param timeout    锁过期时间
     * @param unit 时间单元
     * @return 是否获得竞争锁
     * @throws InterruptedException 线程中断异常
     *//*

    @Override
    public boolean tryLock(String lockKey, int tryTimeOut, int timeout, TimeUnit unit) throws InterruptedException {
        RLock lock = redissonClient.getLock(lockKey);
        return lock.tryLock(tryTimeOut, timeout, unit);
    }

}
*/
